﻿Public Class PTIC_TreeView

#Region "Déclarations liés à l'utilisation des API"

    Private Const WM_PAINT As Integer = 15
    Private Const WM_SIZE As Integer = &H5
    Private Const WM_ERASEBKGND = &H14

    Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Integer) As Integer
    Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Integer, ByVal hDC As Integer) As Integer
    Declare Function setCursorPos Lib "user32" (ByVal x As Integer, ByVal y As Integer) As Integer
    Declare Function createRoundRectRgn Lib "gdi32" _
        (ByVal x1 As Integer, ByVal y1 As Integer, ByVal x2 As Integer, ByVal y2 As Integer, ByVal x3 As Integer, ByVal y3 As Integer) As Integer
    Declare Function setWindowRgn Lib "user32" _
        (ByVal hwnd As IntPtr, ByVal hrgn As IntPtr, ByVal bRedraw As Boolean) As Integer

#End Region

#Region "Variables de classe"
    Private _bordsArrondis As Boolean
#End Region

#Region "Constructeur"
    Public Sub New()
        ' Cet appel est requis par le Concepteur Windows Form.
        InitializeComponent()
    End Sub
#End Region

#Region "Interception des évènements"
    Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        Select Case m.Msg
            'Case WM_PAINT
            'MyBase.WndProc(m)
            'OnPaint()
            Case WM_ERASEBKGND
                m.Result = IntPtr.Zero
            Case Else
                MyBase.WndProc(m)
        End Select
    End Sub
#End Region

#Region "Surcharge des méthodes de redimensionnement / dessin"

    'Protected Overloads Sub OnPaint()

    'Récupération du device context du control
    'Dim hDC As IntPtr = GetWindowDC(Me.Handle)
    'Récupération de la zone graphique associée au device context
    'Dim gfx As Graphics = Graphics.FromHdc(hDC)

    'Déclaration du rectangle dan lequel la bordure va être tracée
    'Dim rcItem As Rectangle = New Rectangle(0, 0, Me.Bounds.Width, Me.Bounds.Height)
    'Tracé de la bordure
    'DrawBorder(gfx, rcItem, Color.FromArgb(101, 147, 207), 1)
    'On supprime la bordure du bas
    'gfx.DrawLine(New Pen(Me.BackColor, 1), 0, Me.Bounds.Height, Me.Bounds.Width, Me.Bounds.Height)

    'Dim lpen As New Pen(My.Settings.OMANE_ColorBorder, 1)

    'gfx.DrawLine(New Pen(My.Settings.OMANE_ColorBorder, 1), 0, 0, 0, Me.Bounds.Height - 1)
    'gfx.DrawLine(New Pen(My.Settings.OMANE_ColorBorder, 1), 0, 0, Me.Bounds.Width - 1, 0)
    'gfx.DrawLine(New Pen(My.Settings.OMANE_ColorBorder, 1), Me.Bounds.Width - 1, 0, Me.Bounds.Width - 1, Me.Bounds.Height - 1)
    'gfx.DrawLine(New Pen(My.Settings.OMANE_ColorBorder, 1), 0, Me.Bounds.Height - 1, Me.Bounds.Width - 1, Me.Bounds.Height - 1)

    'lpen.Dispose()

    'ReleaseDC(Me.Handle, hDC)

    'On ferme l'objet graphique
    'gfx.Dispose()

    'End Sub
    'Private Sub DrawBorder(ByRef Gfx As Graphics, ByVal rcItem As Rectangle, _
    '   ByVal couleurBordure As Color, ByVal tailleBordure As Integer)

    'Dim lpPen As Pen = New Pen(couleurBordure, tailleBordure)
    '    Gfx.DrawLine(lpPen, rcItem.X, rcItem.Y + rcItem.Height - 1, rcItem.X, rcItem.Y)
    '    Gfx.DrawLine(lpPen, rcItem.X, rcItem.Y, rcItem.X + rcItem.Width - 1, rcItem.Y)
    '    If Not (rcItem.Width = 0) Then
    '        Gfx.DrawLine(lpPen, rcItem.X + rcItem.Width - 1, rcItem.Y, rcItem.X + rcItem.Width - 1, rcItem.Top + rcItem.Height - 1)
    '        Gfx.DrawLine(lpPen, rcItem.X + rcItem.Width - 1, rcItem.Top + rcItem.Height - 1, rcItem.X, rcItem.Top + rcItem.Height - 1)
    '    End If
    '    lpPen.Dispose()
    '
    'End Sub
#End Region

End Class
